Multiply two Numbers

03-11-17 Course- CPP

In this program, user is asked to enter two numbers(either integers or floating point numbers) and this program will mulitply these two numbers and display it.

Source Code


/*C++ program to multiply and display the product of two numbers entered by user. */

#include <iostream>
using namespace std;

int main( )
{
    float n1, n2, product;
    cout << "Enter two numbers: ";
    cin >> n1 >> n2;
    product = n1*n2;
    cout << "Product = " << product;
    return 0;
}

Output


Enter two numbers: 2.4
1.6
Product = 3.84

Enter two numbers: 11
13
Product = 143

In this program, user is asked to enter two numbers. These two numbers entered by user will be stored in variables n1 and n2 respectively. This is done using cin() function. Then, * operator is used for multiplying variables and this value is stored in variable product.

Then, the product is displayed and program is terminated.